{extend name="common/main"}
<!--支付页面-->
{block name="css"}
<!-- 本页面需要额外添加的css请在此处添加 -->



{/block}

{block name="body"}
<body style="background: rgb(235, 236, 237);position:relative;">

<div class="screen-wrap fullscreen login">
    <form  method="post" name="cart4_form" id="cart4_form">
        <div class="content_success " >
            <div class="con-ct   fo-con">
                <h4 class="successtijiao">订单已经提交成功！</h4>
                <ul class="ct-list">
                    <li>请您在<span>24小时内</span>完成支付，否则订单将自动取消！：</li>
                    <li >订单号：<em>{$order['order_sn']}</em></li>
                    <li>支付金额：<em>￥{$order['order_amount']}元</em></li>
                </ul>
            </div>

            <section class="order-info">
                <div class="order-list">
                    <div class="content ptop0">
                        <div class="panel panel-default info-box">
                            <div class="panel-body" id="pay_div"  >
                                <div class="title" id="zhifutitle" style="border-bottom:1px solid #eeeeee;"> <span class="i-icon-arrow-down i-icon-arrow-up" id="zhifuip"></span> <span class="text">支付方式</span> </div>
                                <ul class="nav nav-list-sidenav" id="zhifu68" style="display:block; border-bottom:none;">
                                    {foreach name="paymentList" item="v"  key="k"}
                                        <li class="clearfix" name="payment_name">
                                            <label>
                                                <input type="radio"   value="{$v['code']}" class="c_checkbox_t" name="pay_radio" />
                                                <div class="fl shipping_title">{$v.name}
                                                    <!--<img src="/plugins/{$v['type']}/{$v['code']}/{$v['icon']}" onClick="change_pay(this);" width="110" height="40" />-->
                                                </div>
                                            </label>
                                        </li>
                                    {/foreach}
                                </ul>
                                <span>输入密码确认支付:</span> <input type="password" name="password" placeholder="" style="border: #f60 solid 1px">
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <div class="pay-btn">
                <input type="hidden" name="order_id" value="{$order['order_id']}" />
                <a href="javascript:void(0);" onClick="pay()" class="sub-btn btnRadius">去支付</a>
            </div>
        </div>
    </form>
</div>
{include file="common/bar"}
</body>
{/block}

{block name="js"}
<!-- 本页面需要额外添加的js请在此处添加 -->
<script src="/layer/layer.js"></script>
<script>
    $(document).ready(function(){
        $("input[name='pay_radio']").first().trigger('click');
    });
       // 切换支付方式
    // function change_pay(obj)
    // {
    //     $(obj).parent().siblings('input[name="pay_radio"]').trigger('click');
    // }

    function pay(){
        var form=document.getElementById("cart4_form");
        var formData=new FormData(form);
        $.ajax({
            url:"{:Url('getCode')}",
            type:'POST',
            data:formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success:function(res){
                if (res.code == 202){
                    layer.msg(res.msg, {shade: 0.5, time: 400, icon: 1}, function(){
                        //选中是否结算订单
                        layer.confirm("余额不足", {btn: ["去充值","在看看"], shade: 0.5}, function(){
                            // 删除权限组
                            window.location.href="{:url('User/recharge')}";//去充值页面

                            // window.location.href=document.referrer; //返回上一个页面并刷新
                        });

                    });
                }
                    console.log(res);
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000,icon: 2});
                    return false;
                }

                layer.msg(res.msg, {shade: 0.5, time: 400, icon: 1}, function(){
                    //跳转支付成功页面  参数(订单id)
                    window.location.href="{:url('ordersn')}?order_id={$order.order_id}";

                });
            }
        });
        // $('#cart4_form').submit();
        // return;
        //微信JS支付
    }
</script>


{/block}